Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(resharding): Resharding state mapping integration #12269

Merged
merged 6 commits into from
Oct 29, 2024

Conversation

staffik
Copy link
Contributor

@staffik staffik commented Oct 21, 2024

Tracking issue: #12050

Summary:

  • Refactor ReshardingManager::process_memtrie_resharding_storage_update() into start_resharding() as it is an entry point to start resharding.
  • Add set_state_shard_uid_mapping() and call it from start_resharding().
  • Test that State mapping integrates with resharding flow in resharding_v3.rs testloop.

Test would fail with MissingTrieValue for children shards if disabled set_state_shard_uid_mapping.

Perhaps test_resharding_v3_base should be as minimal as possible and I should not test State mapping there. But for now I do not see much value in doing it differently.

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 71.25%. Comparing base (7de36d1) to head (2fc80bc).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
chain/chain/src/resharding/manager.rs 93.15% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12269   +/-   ##
=======================================
  Coverage   71.24%   71.25%           
=======================================
  Files         838      838           
  Lines      169020   169074   +54     
  Branches   169020   169074   +54     
=======================================
+ Hits       120424   120475   +51     
+ Misses      43351    43350    -1     
- Partials     5245     5249    +4     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.23% <0.00%> (-0.01%) ⬇️
integration-tests 39.08% <93.33%> (+0.01%) ⬆️
linux 70.65% <8.00%> (-0.03%) ⬇️
linux-nightly 70.84% <93.33%> (+0.01%) ⬆️
macos 50.31% <8.00%> (-0.01%) ⬇️
pytests 1.54% <0.00%> (-0.01%) ⬇️
sanity-checks 1.35% <0.00%> (-0.01%) ⬇️
unittests 64.10% <8.00%> (-0.04%) ⬇️
upgradability 0.21% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@staffik staffik force-pushed the resharding-mapping-integration branch from 9089366 to 103279d Compare October 28, 2024 10:53
@staffik staffik marked this pull request as ready for review October 28, 2024 11:06
@staffik staffik requested a review from a team as a code owner October 28, 2024 11:06
Copy link
Contributor

@shreyan-gupta shreyan-gupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just some minor questions about testing.

Oh, and confirming, we still need to add the integration with state_sync to remove the mapping for a state sync on child shard right?

/// created later.
pub fn process_memtrie_resharding_storage_update(
/// Trigger resharding if shard layout changes after the given block.
pub fn start_resharding(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice... thanks for renaming!

chain/chain/src/resharding/manager.rs Outdated Show resolved Hide resolved
chain/chain/src/resharding/manager.rs Outdated Show resolved Hide resolved
integration-tests/src/test_loop/tests/resharding_v3.rs Outdated Show resolved Hide resolved
integration-tests/src/test_loop/tests/resharding_v3.rs Outdated Show resolved Hide resolved
@staffik staffik force-pushed the resharding-mapping-integration branch from cbc01fa to 2fc80bc Compare October 28, 2024 15:07
Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice and clean integration :)

chain/chain/src/resharding/manager.rs Outdated Show resolved Hide resolved
chain/chain/src/resharding/manager.rs Outdated Show resolved Hide resolved
Comment on lines 88 to 101
match resharding_event_type {
Some(ReshardingEventType::SplitShard(split_shard_event)) => {
self.split_shard(
chain_store_update,
block,
shard_uid,
tries,
split_shard_event,
next_shard_layout,
)?;
}
None => {
tracing::debug!(target: "resharding", ?resharding_event_type, "unsupported resharding event type, skipping");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

chain/chain/src/resharding/manager.rs Outdated Show resolved Hide resolved
) -> io::Result<()> {
let mut store_update = self.store.trie_store().store_update();
let parent_shard_uid = split_shard_event.parent_shard;
// TODO(reshardingV3) No need to set the mapping for children shards that we won't track just after resharding?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call making that a todo. Let's come back to this question when we figure out the full picture for post resharding cleanup.

@staffik staffik added this pull request to the merge queue Oct 29, 2024
chain/chain/src/resharding/manager.rs Show resolved Hide resolved
Comment on lines +121 to 137
// Reshard the State column by setting ShardUId mapping from children to parent.
self.set_state_shard_uid_mapping(&split_shard_event)?;

// Create temporary children memtries by freezing parent memtrie and referencing it.
self.process_memtrie_resharding_storage_update(
chain_store_update,
block,
shard_uid,
vec![split_shard_event.left_child_shard, split_shard_event.right_child_shard],
tries,
split_shard_event.clone(),
)?;

// Trigger resharding of flat storage.
self.flat_storage_resharder.start_resharding(
ReshardingEventType::SplitShard(split_shard_event.clone()),
ReshardingEventType::SplitShard(split_shard_event),
&next_shard_layout,
)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how this is shaping up - split_shard consists of splitting the State, FlatState and MemTrie.

@staffik staffik removed this pull request from the merge queue due to a manual request Oct 29, 2024
@staffik staffik added this pull request to the merge queue Oct 29, 2024
Merged via the queue into master with commit 2747631 Oct 29, 2024
24 checks passed
@staffik staffik deleted the resharding-mapping-integration branch October 29, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants